import NProgress from 'nprogress' // progress bar

NProgress.configure({
    showSpinner: false
})
NProgress.css = {
    'background-color': 'red'
}

export default (router) => {
    router.beforeEach(async (to, from, next) => {
        if (from.name && to.name !== 'distribute') {
            // start progress bar
            NProgress.start()
        }
        if (to.path) {
            if (window._hmt) {
                window._hmt.push(['_trackPageview', '/#' + to.fullPath])
            }
        }
        next()
    })

    router.afterEach(() => {
        // finish progress bar
        NProgress.done()
    })
}